//
//  SQ_Yi_Cell.m
//  Hand-held_kitchen
//
//  Created by 张张烨 on 16/1/19.
//  Copyright © 2016年 dllo. All rights reserved.
//

#import "SQ_Yi_Cell.h"
#import "YIYIYICollectionViewCell.h"
#import "SheQumodel.h"
#import "ZongTouwenjian.pch"
#import "DArencollectionVC.h"
@interface SQ_Yi_Cell ()<UICollectionViewDataSource,UICollectionViewDelegate>
@property(nonatomic,retain)UICollectionView *collectionView;


@end

@implementation SQ_Yi_Cell
- (void)dealloc
{
    [_tupian release];
    [_zi release];
    [_arr release];
    
    [super dealloc];
}
-(instancetype)initWithStyle:(UITableViewCellStyle)style reuseIdentifier:(NSString *)reuseIdentifier
{
    self = [super initWithStyle:style reuseIdentifier:reuseIdentifier];
    if (self) {
      
        
        self.tupian = [[UIImageView alloc]init];
        _tupian.image = [UIImage imageNamed:@"我的1"];
        [self.contentView addSubview:_tupian];
        [_tupian release];
        
        self.zi = [[UILabel alloc]init];
        _zi.font = [UIFont systemFontOfSize:14* KUAN];
        _zi.text = @"达人";
        [self.contentView addSubview:_zi];
        [_zi release];
        
        [self coll];
//        self.arr = [[NSArray alloc]init];
    }
    return self;
}
// 传值重点 重写set方法
-(void)setArr:(NSArray *)arr{
    if (arr != nil) {
        [_arr release];
    }
    
    _arr = [arr retain];
    [_collectionView reloadData];
}


-(void)coll{
    
    
    UICollectionViewFlowLayout *layout = [[UICollectionViewFlowLayout alloc] init];
    // cell大小
    layout.itemSize = CGSizeMake(90 * KUAN, 130 * GAO);
    // 行列间距
    layout.minimumLineSpacing = 5 * KUAN;
    layout.minimumInteritemSpacing = 1 * GAO;
    // 边界
    layout.sectionInset = UIEdgeInsetsMake(0, 10*KUAN, 0, 10*KUAN);
    // 滚动方向
    layout.scrollDirection = UICollectionViewScrollDirectionHorizontal;

    
    // 创建过程类似tableView
   self.collectionView = [[UICollectionView alloc] initWithFrame:CGRectMake(0, 30 * GAO, Width, 180 * GAO) collectionViewLayout:layout];
    _collectionView.backgroundColor = [UIColor whiteColor];
    _collectionView.delegate = self;
    _collectionView.dataSource = self;
    [self.contentView addSubview:_collectionView];
    // 边距
    
    
   

    [_collectionView registerClass:[YIYIYICollectionViewCell class] forCellWithReuseIdentifier:@"cell"];
   
    
}
/**<  coll itmu的个数 */
-(NSInteger)collectionView:(UICollectionView *)collectionView numberOfItemsInSection:(NSInteger)section
{
   
    
    return _arr.count;
}
-(UICollectionViewCell *)collectionView:(UICollectionView *)collectionView cellForItemAtIndexPath:(NSIndexPath *)indexPath{
    YIYIYICollectionViewCell *cell = [collectionView dequeueReusableCellWithReuseIdentifier:@"cell" forIndexPath:indexPath];
    /**<  接收 */
    SheQumodel *m = _arr[indexPath.item];
   /**<  图片 */
    [cell.touxiang sd_setImageWithURL:[NSURL URLWithString:m.head_img]];
    cell.nicheng.text = m.
    nick;
    cell.fensishu.text = [NSString stringWithFormat:@"%@ 粉丝数",m.tongji_be_follow];
    
    return cell;

}
/**<  coll的点击方法 */
-(void)collectionView:(UICollectionView *)collectionView didSelectItemAtIndexPath:(NSIndexPath *)indexPath{
    SheQumodel *m = _arr[indexPath.item];
    [self.delegate tiaotiao:m.user_id];
    
    
}
/**<  分区数 */
-(NSInteger)numberOfSectionsInCollectionView:(UICollectionView *)collectionView{
    return 1;
}











-(void)layoutSubviews
{
    self.zi.frame = CGRectMake(60 * KUAN, 5 * GAO, 70 * KUAN, 35 * GAO);
    self.tupian.frame = CGRectMake(25 * KUAN, 10 * GAO, 20 * KUAN, 20 * GAO);
}





- (void)awakeFromNib {
    // Initialization code
}

- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
